<template>
  <van-button :color="btnColor" @click="handleClick">{{ btnText }}</van-button>
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  name: "GoBackBtn",
  components: {},
  props: {
    btnText: {
      type: String,
      default: "返回",
    },
    btnColor: {
      type: String,
      default: "#3cb52e",
    },
    clickFunc: Function,
  },
  data() {
    return {};
  },
  computed: {},
  watch: {},
  beforeCreate() {},
  created() {},
  beforeMount() {},
  mounted() {},
  beforeUpdate() {},
  updated() {},
  methods: {
    handleClick() {
      if (this.clickFunc) {
        this.clickFunc();
        return;
      }

      // 默认实现
      this.$router.back();
    },
  },
  beforeUnmount() {},
  unmounted() {},
});
</script>

<style scoped lang="scss">
.van-button {
  flex: 1;
}
</style>
